package com.lichuang.fruitvarietysm.goods.entity;

import lombok.Data;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Data
public class Page<T> {

    private int pageSize; //每页显示条数
    private int totalCount; //总条数
    private int pageNo;//当前页
    private int totalPages; //总页数
    private List<T> pageList;//数据
    private int start;//从第几条开始

    private Integer pid;
    private int parent_id;
    private int category_id;
    private String sort;
    private int start_price;
    private int end_price;
    private int attribute_id;




    public int getStart() {
        return start;
    }

    /**
     * 获取中页数
     * @return
     */
    public int getTotalPages() {
        totalPages = totalCount / pageSize;

        if(totalCount % pageSize != 0){
            totalPages++;
        }

        return totalPages;
    }
    public int getStart(int pageNo){

        if(pageNo < 1){
            pageNo = 1;
        }
        else if(getTotalPages()>0&&pageNo > getTotalPages()){
            pageNo = getTotalPages();
        }

        start = (pageNo-1) * pageSize;
        return start;
    }

}
